EBSILON®Professional Online Documentation
EbsScript / Access to attributes / methods of objects
In This Topic
    Access to attributes / methods of objects
    In This Topic

    Access to attributes of an object

    Accordingly, other attributes of the objects of a model (components, lines, macros, value crosses, text fields, OLE object, graphic elements, etc.) can also be accessed - some properties are not available for all object types:

    Syntax

    Description

    Data type

    Example

    absoluteName Complete object name String "::Getriebe::Rechner"
    alignHorz Horizontal alignment TextAlignmentHorizontalEnum T.alignHorz := TextAlignmentHorizontalRight;
    alignVert Vertical alignment TextAlignmentVerticalEnum T.alignVert := TextAlignmentVerticalCenter;
    alwaysDIN Representation according to DIN, classical stream types, some components Boolean T.alwaysDIN := false;
    calcstatus Calculation status 0: Component deactivated, : Component is calculated, 2: Component deactivated, but taken into account for outputs Integer T.calcstatus := 0,1,2;
    calcresultsatiterationstep rue: Result calculation also after each iteration step CalculateResultsAtIterationStepEnum T.calcresultsatiterationstep := CalculateResultsAtIterationStepOnlyLastOne;
    calculationFPROG ID of the user-defined sub-programme (see default value FPROG) Integer KernelScripting, see components 65 und 93
    calculationKernelScript Text of the kernel script created for the component String T.KernelScript := "begin end;";
    calculationKernelScriptAuxiliaryCalls KernelScript specific auxiliary calls ComponentCalculationKernelScriptAuxiliaryCallsEnum T.ComponentCalculationKernelScriptAuxiliaryCall := ComponentCalculationKernelScriptAuxiliaryCallsNo;
    calculationKernelScriptGenerateDefaultEquations KernelScript specific: Generate standard equations automatically ComponentCalculationKernelScriptGenerateDefaultEquationsEnum T.ComponentCalculationKernelScriptGenerateDefaultEquations := ComponentCalculationKernelScriptGenerateDefaultEquationsYes;
    calculationMode Calculation mode of a component:
    Standard, XUI-DLL, KernelScripting
    ComponentCalculationModeEnum T.ComponentCalculationMode := ComponentCalculationModeInternal:
    calculationSequence Default value FSEQ of some components, KernelScripting, XUI-DLL ComponentCalculationSequenceEnum T.ComponentCalculationSequence := TestLib_AreIntegersEqual_AndExit (T.calculationSequence, ComponentCalculationSequenceParallelToOtherComponents;
    color Filling colour of the components (standard: yellow) Integer T.color := $2068FF; // orange
    color2 Alternating colour of a stream Integer T.color2 := $FF0000; // blue
    color3 unused Integer T.color3 := $0000FF; // red
    color4 Colour of the rim one component (standard black) Integer T.color4 := $D0E040; // light blue
    containerMacro The macro in which a component is contained ebsmacro

    println (Getriebe.containerMacro);

    currentPicture Index of the image used to display an object integer T.currentPicture := 0, 1, 2... ;
    description Description text String Messwert.description:="T hinter HD-VW 5";
    description2

    Description text2 (e. g. Leittechnik-Kennung)

    String Messwert.description2:="I0005";
    description3 Description text3 (e. g. Verwendungsbereich) String

    Messwert.description3:="Kessel";

    description4 Description text4 (e. g. Kennzeichen) String Messwert.description4:="X";
    disableEbsScriptEvaluation Deactivate the execution of EbsScripts in text fields - the script text is then output. Boolean Textfeld.disableEbsScriptEvaluation := true;
    drawBodyStyle Display standard graphic and/or picture DrawBodyStyleEnum T.DrawBodyStyle := DrawBodyStyleDefaultAndPicture;
    dualmacro

    Returns the macro interface to a macro and vice versa

    ebsmacrobase VW2_mit_NK.dualMacro
    fontAutoScale Adjust object and/or font size - or no adjustment Integer Getriebe::Rechner.fontAutoScale := 2;
    fontCol Font colour Integer T.fontcol := $480048; // Purpur
    fontName Name of the font String println (T.fontName);
    fontPointSize Size of the font in points Integer T.fontPointSize := 14;
    fontSize Size of the font Integer T.fontSize := -18;
    fullName Full name of the object String "Getriebe::Rechner"
    htmlAutoResize For HTML texts: automatic resizing so that the text is displayed in full Boolean Text.htmlAutoResize := true;
    htmlCSS The CSS of the HTML text field String Text.htmlCSS:= "h1 {color:mediumseagreen; font-weight:bold; font-size:28pt}";
    htmlSyntax Output text unprocessed (false) or interpreted as HTML (true) Boolean Text.htmlSyntax := true;
    name Name of the object String "Rechner"
    parentObject The associated parent object (for macros) ebsobject println (Getriebe::Rechner.parentObject);
    pictureCount Number of images assigned to an object Integer println (Getriebe.pictureCount);
    pipeAtPort Stream connected to the specified connection ebspipe ebscomp(eobj).PipeAtPort(port);
    portCount Number of connections of the component Integer ebscomp(eobject).portCount;
    shape The shape of the component with which it is displayed Integer T.shape := 4;
    shapeCount Number of available shapes of a component Integer println (Getriebe::Kondensator.shapeCount);
    sortString Sort string for the internal calculation kernel object sequence String T.sortString := "bb";
    text The text that was entered in the text field. String println (Text.text); --> {getfilename()}
    textEvaluated The text that is displayed in a text field. String println (Text.textEvaluated); -->AllProperties.ebs
    textDependsOnProfile true: different texts in profiles possible Boolean Text.textDependsOnProfile := true;
    textFromParentProfile true: The text from the parent profile is displayed Boolean Text.textFromParentProfile := false;
    transientState transient calculation: This one time-dependent default value provides the component results of all time-dependent default values of this component at the end of a time step as start values for the next time step. String println (Getriebe::Kondensator.transientState);
    visible Visibility of the object Integer

    Messwert.visible:=false;          // unsichtbar schalten

    width Width of a stream Integer T._1.width := 4; // Leitung an Anschluss 1 auf Breite 4 setzen

     

    The use of this syntax is possible with Ebsvar constants (direct use of the names of the corresponding object in the model) as well as with Ebsvar variables (variables defined in the EbsScript, which point to the objects in the model). Example:

    If there is a pipe with the name H2O_DAMPF_4 in the model and ePipe is declared in EbsScript

    var ePipe:ebsPipe;
    

    then after the assignment

     ePipe:=H2O_DAMPF_4;
    

    the pressure on this line can be accessed with

    epipe.p
    

    as well as with

    H2O_DAMPF_4.p
    

     

    Methods to access attributes of an object

    Accordingly, other attributes of the objects of a model (components, lines, macros, value crosses, text fields, OLE object, graphic elements, etc.) can also be accessed - some properties are not available for all object types:

    Syntax

    Description

    Data type

    Example

    SetDefaultWidth

    Set width of object to the default width. stream: line width  / component: width of border

    - Dampf.setDefaultWidth;
    SetDefaultColor

    Set color of object to the default color. stream: fluid color /  component: color of inner surface

    - Efficiency_meter.setDefaultColor;
    SetDefaultColor2

    Set color 2 of object to the default color. stream: alternating fluid color /  component: not used

    - Dampf.setDefaultColor2;
    SetDefaultColor3

    Set color 3 of object to the default color. stream: not used /  component: not used

    - Dampf.setDefaultColor3;
    SetDefaultFont

    Set font of text of object to the default font. stream: not used /  component: font of text displayed with component

    - Efficiency_meter.setDefaulFont;
    SetDefaultFontColor

    Set font color of text of object to the default font color. stream: not used /  component: font color of text displayed with component

    - Efficiency_meter.setDefaulFontColor;
    SetDefaultFormat Set font color of text of object to the default font color: Textfield: horiz. align:left,  verti. align top - Textfield.setDefaulFormat;
    PipeAtPort Get ebspipe at the port of a component specified by first parameter ebspipe println (Efficiency_meter.PipeAtPort(2));
    CompViaPipeAtPort Get ebscomp connected to the other end of the stream, which is connected to the port of component specified by first parameter ebscomp println (Efficiency_meter.CompViaPipeAtPort(2));
    PipeViaPipeAtPort Get ebspipe connected to the other end of the stream, which is connected to the port of component specified by first parameter ebspipe println(Power_Summarizer.pipeViaPipeAtPort(1));
    DataViaPipeAtPort Get ebspipe or ebscomp connected to the other end of the stream, which is connected to the port of component specified by first parameter ebsdata

    println (Efficiency_meter.dataViaPipeAtPort(2));
    println(Power_Summarizer.dataViaPipeAtPort(1));

    GetEbsValue Get a specificaton or result value - 1. parameter: Name of value (String) ebsvar var ev:ebsvar;
    ev := Kond_1.getEbsValue("KAN");
    GetEbsArray Get a characteristic line (Characteristic) or a result array - 1. parameter: Name of characteristic (String) ebscharline var ec:ebscharline;
    ec := Kond_1.getEbsArray("CKAM1");
    println (ec.x[2]);
    GetEbsMatrix Get a spec matrix or a result matrix- 1. parameter: Name of matrix (String) ebsmatrix var em:ebsmatrix;
    em := Kond_1.getEbsMatrix("MXHTCOEFF");
    GetFamilyOfEbsArrays Get a family of characteristics line (Characteristic field) or a result array - 1. parameter: Name of characteristic field (String) ebsfamilyofcharlines var efoc: ebsfamilyofcharlines;
    efoc := Generator.getfamilyofebsarrays ("FCOSPHI");

     

    Methods of Macro Objects

    Attributes of a macro can also be accessed accordingly.

    Syntax

    Description

    Parameter

    Data type

    Example

    PipeAtPortAlias

    Get ebspipe connected outside the macro to a port of a macro. The port is specified by its short description.

    1: string ebspipe println(VW1_mit_NK.pipeAtPortAlias("port_named_b"));
    CompViaPipeAtPortAlias

    Get ebscomp linked outside the macro via an ebspipe, which is connected outside to a port of a macro. The port is specified by its short description.

    1: string ebscomp println (VW1_mit_NK.compViaPipeAtPortAlias("port_named_b"));
    PipeViaPipeAtPortAlias Get ebspipe linked outside the macro via an ebspipe, which is connected outside to a port of a macro. The port is specified by its short description. 1: string ebspipe println (VW1_mit_NK.pipeViaPipeAtPortAlias("logic_port"));
    DataViaPipeAtPortAlias Get ebsdata object (ebscomp, ebspipe, ..) linked outside the macro via an ebspipe, which is connected outside to a port of a macro. The port is specified by its short description. 1: string ebsdata println (VW1_mit_NK.DataViaPipeAtPortAlias("port_named_b"));
    RunEbsscript It enables the explicit execution of one of the macro ebsScripts "Before calculation", "After calculation" or "Transfer of nominal values." 1: userCodeType:usercodetypeenum
    2: invocation:string = ""
    ebsscriptstatusenum println (enumtostring (VW1_mit_NK.runEbsScript(UserCodeTypeAfterCalculation)));
    GetObjects Allows access to objects within a macro, filtered by type and whether objects from contained macros should also be included. 1: ebsobjecttype:string
    2: includeChildContexts:boolean
    array of ebsobject aeo := VW1_mit_NK.getObjects();
    println (length(aeo));

    Example script using RunEbsscript- executable in the example Block750.ebs

    var rc: ebsscriptstatusenum;
    begin
    clrscr;
    rc := VW2_mit_NK::MacroInterface.runEbsScript(UserCodeTypeAfterCalculation);
    println (enumtostring(rc));
    rc := VW1_mit_NK::MacroInterface.runEbsScript(UserCodeTypeBeforeCalculation);
    println (enumtostring(rc));
    end.

    Output of the script:
    EbsScriptStatusOk
    EbsScriptStatusScriptNotFound
     
    

    Example script using getObjects - executable in the example Block750.ebs

    var aeo: array of ebsobject;  
    eo: ebsobject;
    begin
    aeo := VW2_mit_NK::MacroInterface.getObjects ("ebspipe", true);
    for eo in aeo do begin
    println (eo.name);
    end;
    end.

    Output of the script:
    H2O_FLUESSIG_16
    H2O_FLUESSIG_36
    Dampf
    Wasser_1
    Wasser_2
    Wasser_3